package com.neusoft.work.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.work.dto.CustomerCarePlanDTO;
import com.neusoft.work.po.Customer;
import com.neusoft.work.po.CustomerCarePlan;
import com.neusoft.work.po.PageResponseBean;
import com.neusoft.work.po.ResponseBean;
import com.neusoft.work.service.CustomerCarePlanService;


@RestController
@RequestMapping("/CustomerCarePlanController")
public class CustomerCarePlanController {

    @Autowired
    private CustomerCarePlanService planService;

    @GetMapping("/searchCustomer")
    public ResponseBean<List<Customer>> searchCustomer(String customerName) {
        return planService.searchCustomer(customerName);
    }

    @GetMapping("/searchCustomerCarePlan")
    public ResponseBean<List<CustomerCarePlanDTO>> searchCustomerCarePlan(Integer customerId) {
        return planService.searchCustomerCarePlan(customerId);
    }

    @PostMapping("/addCustomerCarePlan")
    public ResponseBean<Integer> addCustomerCarePlan(CustomerCarePlan ccp) {
        return planService.addCustomerCarePlan(ccp);
    }

    @PostMapping("/updateCustomerCarePlan")
    public ResponseBean<Integer> updateCustomerCarePlan(CustomerCarePlan ccp) {
        return planService.updateCustomerCarePlan(ccp);
    }

    @DeleteMapping("/delCustomerCarePlan")
    public ResponseBean<Integer> delCustomerCarePlan(Integer customerId,String careProjectCode) {
        return planService.delCustomerCarePlan(customerId,careProjectCode);
    }
    
 // 分页查询某客户的护理项目
    @GetMapping("/searchCustomerCarePlanPage")
    public PageResponseBean<List<CustomerCarePlanDTO>> searchCustomerCarePlan(
            @RequestParam Integer customerId,
            @RequestParam Long cur,
            @RequestParam Long number) {
        return planService.searchCustomerCarePlan(customerId, cur, number);
    }
}
